<?php

class sfWidgetChoiceWithAdd extends sfWidgetFormDoctrineChoice{
    protected function configure($options = array(), $attributes = array()){
        $this->addRequiredOption('add_url');
        $this->addOption('window_width', 300);
        $this->addOption('window_height', 200);
        
        parent::configure($options, $attributes);
    }
    
    public function render($name, $value = null, $attributes = array(), $errors = array()){
        
        return parent::render($name, $value, $attributes, $errors).
                "<input type='button' onclick='window.open(\"".url_for($this->getOption('add_url').'?rel_input='.$this->generateId($name))."\", \"AddWindow\", \"width=".$this->getOption('window_width').",height=".$this->getOption('window_height')."\"); return false;' value='".I18nUtilities::__('Create New')." +' />";
    }
}